//
//  DomExtension.m
//  WebClipper
//
//  Created by Daniel Braun on 15/04/07.
//  Copyright 2007 Daniel Braun http://page-appart.net, http://braun.daniel.free.fr All rights reserved.
//

#import "DomExtension.h"


@implementation DOMNode (NextElem)
- (DOMNode *) nextElement
{
	DOMNode *e=[self nextSibling];
	if (e) return e;
	e=self;
	for (;;) {
		e=[e parentNode];
		if (!e) return nil;
		DOMNode *n=[e nextSibling];
		if (!n) continue;
		while (![n hasChildNodes]) {
			n=[n nextSibling];
			if (!n) break;
		}
		if (!n) continue;
		return [n firstChild];
	}
	return nil;
}


@end
